home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / query / mquery / msort.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-05-24  |  3.2 KB  |  115 lines

  1. VERSION 2.00
  2. Begin Form fSort 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Sort Records"
  6.    ClientHeight    =   2370
  7.    ClientLeft      =   3090
  8.    ClientTop       =   3120
  9.    ClientWidth     =   5070
  10.    ControlBox      =   0   'False
  11.    Height          =   2835
  12.    Left            =   3000
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   2412
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   5160
  19.    Top             =   2745
  20.    Width           =   5250
  21.    Begin ListBox cFieldList 
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1395
  24.       Left            =   240
  25.       TabIndex        =   1
  26.       Tag             =   " OL"
  27.       Top             =   360
  28.       Width           =   1695
  29.    End
  30.    Begin CommandButton OkayButton 
  31.       Caption         =   "&OK"
  32.       Default         =   -1  'True
  33.       Enabled         =   0   'False
  34.       Height          =   372
  35.       Left            =   2340
  36.       TabIndex        =   3
  37.       Top             =   420
  38.       Width           =   1691
  39.    End
  40.    Begin CommandButton CancelButton 
  41.       Cancel          =   -1  'True
  42.       Caption         =   "&Cancel"
  43.       Height          =   372
  44.       Left            =   2340
  45.       TabIndex        =   0
  46.       Top             =   1320
  47.       Width           =   1691
  48.    End
  49.    Begin Label FieldListLabel 
  50.       BackColor       =   &H00C0C0C0&
  51.       Caption         =   "Fields:"
  52.       Height          =   192
  53.       Left            =   240
  54.       TabIndex        =   2
  55.       Top             =   120
  56.       Width           =   1092
  57.    End
  58. Option Explicit
  59. Dim FNotFound As Integer
  60. Sub CancelButton_Click ()
  61.   Hide
  62.   'set the flag for the dynaset/dynagrid form
  63.   gfFindFailed = True
  64. End Sub
  65. Sub cFieldList_Click ()
  66.   If cFieldList <> "" Then
  67.     OkayButton.Enabled = True
  68.   Else
  69.     OkayButton.Enabled = False
  70.   End If
  71. End Sub
  72. Sub Form_Load ()
  73.    Me.Left = (screen.Width - Me.Width) / 2
  74.    Me.Top = (screen.Height - Me.Height) / 2
  75. End Sub
  76. Sub Form_Paint ()
  77.   Outlines Me
  78. End Sub
  79. Sub OkayButton_Click ()
  80.    Dim i As Integer
  81.    Dim k As Integer
  82.    Dim stripedSort As String
  83.    On Error GoTo FindErr
  84.    FNotFound = False
  85.    SetHourGlass Me
  86.     gSortStr = cFieldList
  87.     stripedSort = gSortStr ' needed for compare later
  88.     gSortStr = "[" + gSortStr + "]"
  89.       
  90. ' see if this was not a stored query..if not add to SQL statement for save
  91.  If Not gStoredFlag Then
  92.     i = InStr(1, UCase(gstDynaString), "ORDER BY") 'see if a where exists
  93.         If i = 0 Then
  94.             gstDynaString = Trim(gstDynaString) & " Order By " & gTblname & "." & gSortStr
  95.         Else
  96.             k = InStr(i + 8, UCase(gstDynaString), UCase(stripedSort))' is this sort already used?
  97.             If k = 0 Then
  98.                 gstDynaString = Trim(gstDynaString) & "," & gTblname & "." & gSortStr
  99.             End If
  100.         End If
  101.  End If
  102.    Hide
  103.    GoTo FindEnd
  104. FindErr:
  105.    If Err <> EOF_ERR Then
  106.      ShowError
  107.      Resume FindEnd
  108.    Else
  109.      FNotFound = True
  110.      Resume Next
  111.    End If
  112. FindEnd:
  113.    ResetMouse Me
  114. End Sub
  115.